

$(document).ready(function(){
var type=$("#eachType").val();
findEachPicList(type);	
	
})

function searchuser(){
	var type=$("#eachType").val();
	findEachPicList(type);
}

function findEachPicList(type){
	
	    $.ajax({
        type: "POST",
        url: urlcore + "/api/eachPicture/findEachPicList?type="+type,
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data:{
        	 
        },
        success: function (data) {
        	$("#thislist").html("");
        	var da=data.data,pictureUrl="",html="";
           for(var i=0,y=da.length;i<y;i++){
           	pictureUrl = da[i].pictureUrl != null ? da[i].pictureUrl : "";
           	var eachTypeStr="";
           	if(da[i].eachType==1){
           		eachTypeStr="蜜哆哆首页轮播";
           	}else if(da[i].eachType==2){
           		eachTypeStr="蜜雅阁首页轮播";
           	}else if(da[i].eachType==3){
           		eachTypeStr="品牌馆首页轮播";
           	}else if(da[i].eachType==4){
                eachTypeStr="试用众测首页图片";
            }else if(da[i].eachType==5){
                eachTypeStr="新品首发首页图片";
            }else if(da[i].eachType==6){
                eachTypeStr="品牌推荐首页图片";
            }else if(da[i].eachType==7){
                eachTypeStr="首次登录轮播";
            }else if(da[i].eachType==8){
                eachTypeStr="启动广告图";
            }else if(da[i].eachType==9){
                eachTypeStr="首页弹窗图";
            }else if(da[i].eachType==10){
                eachTypeStr="体验推荐banner图";
            }
           	
      html += "  <tr >\n" +
              "  \t\t<td>" + (i + 1) + "</td>\n" +
            "  \t\t<td>" + eachTypeStr + "</td>\n" +
            "\t\t <td class=\"footable-visible\"><img width=\"auto\" height=\"50px\" src=\"" + pictureUrl + "\"></td>\n" +
            "  \t\t<td>" + (da[i].goodsId!=null?da[i].goodsId:"") + "</td>\n" +
            "  \t\t<td>" + (da[i].intentUrl!=null?da[i].intentUrl:"") + "</td>\n" +
            "  \t\t<td>\n" +
            "   \t\t<a class=\"btn btn-primary btn-xs\" href=\"javascript:;\" onclick=\"doDelete(" + da[i].id + ")\"> 删除</a>\n" +
            "  \t\t</td>\n" +
            "  \t</tr>";
           	
           }
           $("#thislist").append(html);
          
        },
        error: function () {
            alert("失败");
        }
    });

	
	
}


function doDelete(id){
	
	   $.ajax({
        type: "GET",
        url: urlcore + "/api/eachPicture/doDelete?id=" + id,
        dataType: "json",
        headers: {"Content-Type": "application/json;charset=UTF-8"},
        data: {},
        success: function (data) {//data是返回的hash,key之类的值，key是定义的文件名
            if (data.success == true) {
                location.reload();
            } else {
                alert(data.msg);
            }
        },
        error: function () {
            alert("删除失败");
        }
    });
	
	
}


function scPic(){
    var type = $("#eachType").val();
    window.location.href = "eachPic.html?type="+type;
}








